package cn.wzy.controller;



import cn.wzy.annotation.AnPermission;
import cn.wzy.pojo.CarType;
import cn.wzy.results.ResponseResult;
import cn.wzy.service.CarTypeService;
import cn.wzy.vo.GoPageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.annotation.TableName;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (CarType)表控制层
 *
 * @author makejava
 * @since 2023-01-24 10:49:10
 */
@RestController
@RequestMapping("carType")
@ApiOperation(value = "车辆类型管理")
@AnPermission(name = "车辆类型管理")
public class CarTypeController{
    /**
     * 服务对象
     */
    @Resource
    private CarTypeService carTypeService;
    
    /*
    * 查询分页
    * */
    @PostMapping("/page")
    @ApiOperation(value = "车辆类型管理分页查询",tags = "分页")
    @AnPermission(name = "车辆类型管理分页查询")
    public ResponseResult getCarTypePage(@RequestBody GoPageVo goPageVo){
        return carTypeService.getCarTypePage(goPageVo);
    }

    /*
    * 查询
    * */
    @GetMapping("/{id}")
    @AnPermission(name = "车辆类型管理id查询")
    @ApiOperation(value = "车辆类型管理id查询")
    public ResponseResult getCarType(@PathVariable("id") Long id){
        return carTypeService.getCarType(id);
    }

    /*
    * 新增和修改
    * */
    @PostMapping
    @AnPermission(name = "车辆类型修改或者添加")
    @ApiOperation(value = "车辆类型新增或者修改")
    public ResponseResult saveCarType(@RequestBody CarType carType){
        return carTypeService.saveCarType(carType);
    }

    /*
    * 删除
    * */
    @DeleteMapping("/{id}")
    @AnPermission(name = "id删除车辆类型")
    @ApiOperation(value = "删除车辆类型")
    public ResponseResult deleteCarType(@PathVariable("id") Long id){
        carTypeService.deleteCarType(id);
        return ResponseResult.okResult();
    }


    /*
    * 批量删除
    * */
    @PatchMapping
    @AnPermission(name = "批量删除车辆类型")
    @ApiOperation(value = "批量删除车辆类型")
    public ResponseResult deleteCarTypeList(@RequestBody List<Long> ids){
        return carTypeService.deleteCarTypeList(ids);
    }


    /*
    * 无限极树
    * */
    @GetMapping("/tree")
    @AnPermission(name = "车辆类型无限极树")
    @ApiOperation(value = "车辆类型无限极树")
    public ResponseResult tree(){
        List<CarType> carTypeList = carTypeService.tree(0L);
        return ResponseResult.okResult(carTypeList);

    }



}

